package com.woniuxy01;

import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;

/**
 * @author 作者
 * @create 2025-06-10 9:27
 */
class Animal {}
class Dog extends Animal{}
class Cat extends Animal {}


public class Test02 {
    public static void main(String[] args) {
       List<Animal> animals1 = new ArrayList<Animal>();
       List<?> animals2 = new ArrayList<Object>();
       List<?> animals3 = new ArrayList<Animal>();
       List<?> animals4 = new ArrayList<Dog>();
       List<?> animals5 = new ArrayList<Cat>();

       //兼容本类及其子类
       List<? extends Animal> animals6 = new ArrayList<Animal>();
       List<? extends Animal> animals7 = new ArrayList<Dog>();
       List<? extends Animal> animals8 = new ArrayList<Cat>();
//       List<? extends Animal> animals9 = new ArrayList<Object>();

        //兼容本类及其父类
        List<? super Animal> animals10 = new ArrayList<Animal>();
        List<? super Animal> animals11 = new ArrayList<Object>();
//        List<? super Animal> animals12 = new ArrayList<Cat>();
//        List<? super Animal> animals13 = new ArrayList<Dog>();
    }


}
